/*
 * =====================================================================================
 *
 *       Filename:  adapter.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  02/16/2011 11:33:10 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  dp (8023), dp8023@gmail.com
 *        Company:  
 *
 * =====================================================================================
 */

#ifndef _ADAPTER_H_
#define _ADAPTER_H_

#include	<iostream>

using namespace std;

class cnoutlet
{
	public:
		cnoutlet(){}
		virtual ~cnoutlet(){}

		virtual void plug() = 0;
};

class enoutlet
{
	public:
		enoutlet(){}
		~enoutlet(){}

		void plug()
		{
			cout << "Use en outlet." << endl;
		}
};

class adapter:public cnoutlet
{
	public:
		adapter(){}
		adapter(enoutlet *p_outlet):m_outlet(p_outlet){}
		~adapter()
		{
			if (m_outlet)
			{
				delete m_outlet;
				m_outlet = NULL;
			}
		}

		void plug()
		{
			cout << "wanna use cn outlet." << endl;
			cout << "adapter transfer...." << endl;
			m_outlet->plug();
		}

	private:
		enoutlet *m_outlet;
};

#endif

